<template>
  <div class="page-wrap">
    <div class="page-content" :style="{ height: contentHei }">
      <div class="img-header">
        <div style="font-weight: 700;font-size: 18px" @click="showVal">测试MarkDown编辑</div>
        <div style="display: flex;justify-content: flex-end;"></div>
      </div>
      <Divider />
      <div class="table-wrap">
        <mavon-editor
          v-model="value"
          :subfield="prop.subfield"
          :defaultOpen="prop.defaultOpen"
          :toolbarsFlag="prop.toolbarsFlag"
          :editable="prop.editable"
          :scrollStyle="prop.scrollStyle"
        />
        <!--<div class="wrap-quepe" v-text="md"  v-highlight></div>-->
      </div>
    </div>
  </div>
</template>
<script>
import $ from 'jquery';
import encryption from '@/libs/encryption.js';
// const marked = require('marked')
import 'highlight.js/styles/atom-one-dark.css';
export default {
  data() {
    return {
      // 用户信息
      USER_ID: '',
      isRootDesigner: '',
      // 页面设置
      fullHeight: document.documentElement.clientHeight,
      fullWidth: document.documentElement.clientWidth,
      contentHei: 'auto',
      //
      value:
        '# new-vue-project\n' +
        '\n' +
        '> A Vue.js project\n' +
        '\n' +
        '## Build Setup\n' +
        '\n' +
        '``` bash\n' +
        '# install dependencies\n' +
        'npm install\n' +
        '\n' +
        '# serve with hot reload at localhost:8080\n' +
        'npm run dev\n' +
        '\n' +
        '# build for production with minification\n' +
        'npm run build\n' +
        '\n' +
        '# build for production and view the bundle analyzer report\n' +
        'npm run build --report\n' +
        '```\n' +
        '\n' +
        'For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).\n' +
        '#发布时的注意事项：\n' +
        'src>view>competition>taskCDetail下的‘<a href="./static/解题报告模板.docx" download="" class="downclass">模板下载</a>’改成\n' +
        '‘<a href="static/解题报告模板.docx" download="" class="downclass">模板下载</a>’',
      md: '',
      context: ' ', //输入的数据
      toolbars: {
        bold: true, // 粗体
        italic: true, // 斜体
        header: true, // 标题
        underline: true, // 下划线
        mark: true, // 标记
        superscript: true, // 上角标
        quote: true, // 引用
        ol: true, // 有序列表
        link: true, // 链接
        imagelink: true, // 图片链接
        help: true, // 帮助
        code: true, // code
        subfield: true, // 是否需要分栏
        fullscreen: true, // 全屏编辑
        readmodel: true, // 沉浸式阅读
        /* 1.3.5 */
        undo: true, // 上一步
        trash: true, // 清空
        save: true, // 保存（触发events中的save事件）
        /* 1.4.2 */
        navigation: true // 导航目录
      }
    };
  },
  computed: {
    prop() {
      let data = {
        subfield: false, // 单双栏模式
        defaultOpen: 'preview', //edit： 默认展示编辑区域 ， preview： 默认展示预览区域
        editable: false,
        toolbarsFlag: false,
        scrollStyle: true
      };
      return data;
    }
  },
  created() {
    // 获取用户id
    let November = sessionStorage.getItem('November');
    November = JSON.parse(encryption.SelfUseDecrypt(November));
    this.USER_ID = November.userId;
    this.isRootDesigner = November.isRootDesigner;
    // 调用marked函数，传入markdown格式的内容，返回一段html
    // this.md = marked(this.value)
  },
  mounted() {
    this.setStyle();
    window.onresize = () => {
      this.setStyle();
    };
  },
  methods: {
    // 设置高度
    setStyle() {
      window.fullHeight = document.documentElement.clientHeight;
      window.fullWidth = document.documentElement.clientWidth;
      this.fullHeight = window.fullHeight;
      this.fullWidth = window.fullWidth;
      this.contentHei = this.fullHeight - 80 - 60 + 'px'; // 80是头部高度  60是上下padding
    },
    showVal() {}
  }
};
</script>
<style scoped>
.page-wrap {
  padding: 30px;
}
.page-content {
  background-color: #fff;
  border-radius: 10px;
}
.img-header {
  display: flex;
  justify-content: space-between;
  padding: 20px 20px 0 20px;
}
.table-wrap {
  padding: 0 30px;
}
</style>
<style>
.wrap-quepe blockquote {
  border-left: #dfe2e5 solid 5px;
  padding-left: 15px;
  color: #8e8e8e;
  margin-inline-start: 0px;
  margin-inline-end: 0px;
}
.wrap-quepe ul li {
  line-height: 25px;
}
.wrap-quepe pre code {
  background: #f6f6f6;
}
.wrap-quepe p code {
  color: #d34b62;
  background: #f6f6f6;
  margin: 0 2px;
}

@keyframes squeezeBody {
  from {
    width: 100%;
  }
  to {
    width: calc(100% - 300px);
  }
}

@-webkit-keyframes squeezeBody {
  from {
    width: 100%;
  }
  to {
    width: calc(100% - 300px);
  }
}

@keyframes stretchBody {
  from {
    width: calc(100% - 300px);
  }
  to {
    width: 100%;
  }
}

@-webkit-keyframes stretchBody {
  from {
    width: calc(100% - 300px);
  }
  to {
    width: 100%;
  }
}

.squeezed-body {
  animation: squeezeBody 0.5s ease;
  -webkit-animation: squeezeBody 0.5s ease;
  width: calc(100% - 300px);
}

.full-body {
  animation: stretchBody 0.5s ease;
  -webkit-animation: stretchBody 0.5s ease;
  width: 100%;
}

.wrap-quepe h1,
.wrap-quepe h2,
.wrap-quepe h3,
.wrap-quepe h4,
.wrap-quepe h5,
.wrap-quepe h6 {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif,
    'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
  font-weight: bold;
  margin-top: 24px;
  margin-bottom: 16px;
}

.wrap-quepe h1 {
  border-bottom: 1px solid #ddd;
}

.wrap-quepe .serif {
  font-family: 'Old Standard TT', serif;
}

.wrap-quepe .top-bar {
  height: 45px;
  min-height: 45px;
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
}

.wrap-quepe .bars-lnk {
  color: #fff;
}

.wrap-quepe .bars-lnk i {
  display: inline-block;
  margin-left: 10px;
  margin-top: 7px;
}

.wrap-quepe .bars-lnk img {
  display: inline-block;
  margin-left: 10px;
  margin-top: -15px;
  margin-right: 15px;
  height: 35px;
}

.wrap-quepe .lateral-menu {
  background-color: #333;
  color: rgb(144, 144, 144);
  width: 300px;
  font-family: 'Open Sans', 'Myriad Pro', 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans',
    Geneva, Verdana, sans-serif;
}

.wrap-quepe .lateral-menu label {
  color: rgb(144, 144, 144);
}

.wrap-quepe .lateral-menu-content {
  padding-left: 10px;
  height: 100%;
  font-size: 12px;
  font-style: normal;
  font-variant: normal;
  font-weight: bold;
  line-height: 16px;
}

.wrap-quepe .lateral-menu-content .title {
  padding-top: 15px;
  font-size: 2em;
  height: 45px;
}

.wrap-quepe .lateral-menu-content-inner {
  overflow-y: auto;
  height: 100%;
  padding-top: 10px;
  padding-bottom: 50px;
  padding-right: 10px;
  font-size: 0.9em;
}

.wrap-quepe .container {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: stretch;
  width: 100%;
  height: 100%;
  padding-top: 65px;
}

.wrap-quepe .container > * {
  display: block;
  width: 50%;
  margin-left: 10px;
  margin-right: 10px;
  max-height: 100%;
}

.wrap-quepe .container textarea {
  resize: none;
  font-family: Consolas, 'Liberation Mono', Courier, monospace;
  height: 97%;
  max-height: 97%;
  width: 45%;
}

.wrap-quepe #preview {
  height: 97%;
  max-height: 97%;
  border: 1px solid #eee;
  overflow-y: scroll;
  width: 55%;
  padding: 10px;
}

.wrap-quepe pre {
  white-space: pre-wrap;
  /* css-3 */
  white-space: -moz-pre-wrap;
  /* Mozilla, since 1999 */
  /* Opera 4-6 */
  white-space: -o-pre-wrap;
  /* Opera 7 */
  word-wrap: break-word;
  /* Internet Explorer 5.5+ */
  background-color: #f8f8f8;
  border: 1px solid #dfdfdf;
  margin-top: 1.5em;
  margin-bottom: 1.5em;
  padding: 0.125rem 0.3125rem 0.0625rem;
}

.wrap-quepe pre {
  padding: 16px;
  overflow: auto;
  font-size: 85%;
  line-height: 1.45;
  background-color: #f6f8fa;
  border-radius: 3px;
}

.wrap-quepe .modal-wrapper {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  z-index: 999;
  background-color: rgba(51, 51, 51, 0.5);
}

.wrap-quepe .modal-inner {
  margin-top: 200px;
  margin-left: auto;
  margin-right: auto;
  width: 600px;
  height: 225px;
  background-color: #fff;
  opacity: 1;
  z-index: 1000;
}

.wrap-quepe .modal-close-btn {
  float: right;
  display: inline-block;
  margin-right: 5px;
  color: #ff4336;
}

.wrap-quepe .modal-close-btn:hover {
  float: right;
  display: inline-block;
  margin-right: 5px;
  color: #8d0002;
}

.wrap-quepe .modal-topbar {
  clear: both;
  height: 25px;
}

.wrap-quepe .modal-inner .link-area {
  margin: 10px;
  height: 170px;
}

.wrap-quepe .modal-inner textarea {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}

.wrap-quepe .version {
  color: white;
  font-size: 0.8em !important;
}
</style>
